<#setting url_escaping_charset='utf-8'>
<!-- DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" -->
<!-- DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd" -->
<html>
<head>
<#include "/WEB-INF/ftl_lib/commonftl/grid_meta.ftl"/>
<!-- 如果不需要 日期组件 功能,请将下面 4行 代码去掉 -->
<#include "/WEB-INF/ftl_lib/commonftl/common_meta.ftl"/>
<title>website列表</title>
<script type="text/javascript" >
///////////////////////////////////////
var contentConfigJson = ${contentConfigJson};
var tplContent = ${tplContent};
//alert(tplContent);
//for(var i in contentConfigJson){alert(i);alert(contentConfigJson[i]);}
//alert(typeof contentConfigJson);
//alert(contentConfigJson);
var flagList = {"1":"Yes", "0":"No"};
//alert("--"+flagList);
var myDialogEditorCreater = new Sigma.DialogEditor({
id: "myDialogEditor1",
gridId : "myGrid1" ,
width: 600,
height:200 ,
title : '姓名 编辑器',
body : ['<textarea id="my_description_input" rows="20" cols="20" style="width:99%"></textarea><br/>',
'<input type="button" value="确定" onclick="Sigma.$grid(\'myGrid1\').activeDialog.confirm()"/>'].join(''),
/****
指定存放编辑器值的 页面元素 或 该元素的id 或可以取得该元素的函数, 有时候它未必是直接被用户操作的元素,也许是一个hidden input.
元素形式:
valueDom : Sigma.$("my_description_input")
函数形式:
函数形式的作用: 有时候在创建editor时,那个valueDom 元素也许还并不存在,
或者是不同环境下对valueDom有不同的需求,需要通过if 来做判断,那么 函数形式就派上用场了.
valueDom : function(){ return Sigma.$("my_description_input") }
****/
// valueDom :"my_description_input" ,
// 更高级的用法是 重写 setValue getValue方法,这样你就可以"为所欲为"了. 例子如下:
getValue : function(){
return Sigma.$("my_description_input").value;
},
setValue : function(value){
Sigma.$("my_description_input").value=value;
},
// 其实 仅仅重写这两个方法是不够的, 有时候你希望打开编辑器的时候,自动让某个元素得到焦点,所以还应该重新 active 方法.
active : function(){
Sigma.U.focus(Sigma.$("my_description_input")); // 你可以指定任何一个可以得到焦点的元素得到焦点,不一定非要是 valueDom
}
// 如果你的 valueDom 可以取得, 那么 你完全没有必要重写 getValue setValue....
// 而且 Dialog 是有 beforeShow afterShow beforeHide afterHide 方法的
// 可以通过重写这些方法 做一些before拦截和 after处理 以及对 Dialog 的数据校验
});
var grid_demo_id = "myGrid1" ;
var dsOption= {
fields :[
{name : 'id' ,type:'int' },
{name : 'title',type: 'string' },
{name : 'channel',type: 'string' },
{name : 'tags',type: 'string' },
{name : 'releaseDate',type: 'date' },
{name : 'contentConfigId',type:'int' },
{name : 'tplContent',type:'string' },
{name : 'shortTitle',type: 'string' },
{name : 'titleImg',type: 'string' },
{name : 'description',type: 'string' },
{name : 'author',type: 'string' },
{name : 'origin',type: 'string' },
{name : 'outerUrl',type: 'string' },
{name : 'titleColor',type: 'string' }
/*,
{name : 'sortDate',type: 'date' },
{name : 'releaseSysDate',type: 'date' }*/
],
uniqueField : 'id'
}
var colsOption = [
{id: 'chk' ,isCheckColumn : true, _checkType:'radio' ,frozen : false , filterable : false, header: "", title: "全选" , fieldName : 'id'},
{id: 'id' , header: "id" , width :35 },
{id: 'title' , header: "文章标题" , width :200, editable:true, editor: { type :'text' },
renderer : function(value ,record,columnObj,grid,colNo,rowNo){
if(value == undefined){
return null;
}else{
return value;
//return ' <a href="${base}'+record['url']+'" target="_blank" style="margin-left:3px;" > '+ '<font color="blue" style="font-weight:bold">['+record['channel']['name']+']</font>'+record['title'] +'  </a>';
}
}
},
{id: 'channel' , header: "所属栏目" , width :100 ,
renderer : function(value ,record,columnObj,grid,colNo,rowNo){
if(value == undefined){
return "";
}else{
return record['channel']['name'];
}
}
},
{ id : 'tags' , header : "关键字" , width : 200 , editable:true ,editor: { type :'text' } },
{id: 'releaseDate' , header: "发布日期" , width :100,
editor : { type :"date" ,validRule : ['date'] ,validator : null , format : "yyyy-MM-dd" }
},
{ id : 'channel' , header : "操作" , width : 120,
renderer : function(value ,record,columnObj,grid,colNo,rowNo){
if(value == undefined){
return "";
}else{
return ' | <a href="'+record['url']+'" target="_bank" title="预览">预览</a>'
+' | <a href="${base}/cms/article/article!edit.action?channelId='+record['channel']['id']+'&isLeaf=${isLeaf}&id='+record['id']+'" title="修改">修改</a>';
}
}
},
// http://group.gimoo.net/review/138090 看范例
{id: 'contentConfigId' , header: "内容属性" , width :100 ,
//renderer : Sigma.Grid.mappingRenderer(contentConfigJson),
renderer : function(value, record, columnObj, grid, colNo, rowNo)
{
//alert(value);
//alert(contentConfigJson[record['articleContentConfig']['id']]);
// var backValue = record['articleContentConfig']['id'];//初始化列表,存在值
// alert(backValue);
if( value == undefined){
return contentConfigJson[record['articleContentConfig']['id']] ? contentConfigJson[record['articleContentConfig']['id']] : '';
}else{
//alert(contentConfigJson[value]);
return contentConfigJson[value] ? contentConfigJson[value] : '';
}
},
editor : {
type : 'select',
deafultText : "普通",
options : contentConfigJson
}
},
{id: 'tplContent' , header: "文章模板" , width :200 ,
renderer : Sigma.Grid.mappingRenderer(tplContent),//可以动态取得数据库里面的值
editor : {
type : 'select',
deafultText : "/article/default/content.ftl",
options : tplContent
}
},
{ id : 'shortTitle' , header : "简短标题" , width : 100 , editable:true ,editor: { type :'text' } },
{id: 'titleColor' , header: "标题颜色" , width :100 },
{id: 'description' , header: "描述" , width :200 ,chartCaption : '{@} 的成绩', toolTip : true ,toolTipWidth : 150 ,
frozen : false ,
editor : myDialogEditorCreater ,
//getSortValue : function(value,record){
// return String(value).length;
//},
sortFn :function(r1,r2,sortOrder){
if (sortOrder=='desc'){
return String(r2[1]).localeCompare(r1[1]);
}
return String(r1[1]).localeCompare(r2[1]);
}
},
{ id : 'author' , header : "作者" , width : 100 , editable:true ,editor: { type :'text' }},
{ id : 'origin' , header : "来源" , width : 100 , editable:true ,editor: { type :'text' } },
{ id : 'outerUrl' , header : "外连接" , width : 100 , editable:true ,editor: { type :'text' }},
{id: 'titleImg' , header: "文章标题缩略图" , width :300 }
/*,
{id: 'sortDate' , header: "排序日期" , width :100,
editor : { type :"date" ,validator : null , format : "yyyy-MM-dd" }
},
{id: 'releaseSysDate' , header: "系统日期" , width :100,
editor : { type :"date" ,validator : null , format : "yyyy-MM-dd" }
}*/
];
var gridOption={
//autoSaveOnNav : true ,
//reloadAfterSave : false,
id : grid_demo_id,
/* loadURL 支持函数, 该函数返回值是response对象 -----操作完返回的应该是对应的list列表,不是全部数据的列表--还要测试这样的结果,列表分页有没有存在问题 */
loadURL : '${base}/cms/article/ArticleList.action',
saveURL : '${base}/cms/article/article!doSave.action' ,
remotePaging : true,
width: "880", //"100%", // 700,
height: "460", //"100%", // 330,
container : 'mygrid_container',
toolbarPosition : 'bottom', // 'top', 工具条显示的位置, 暂时不支持上下都显示.
toolbarContent : 'nav | pagesize | reload | add del save | filter | print | state',
pageSizeList : [5,10,20],
dataset : dsOption ,
columns : colsOption ,
recountAfterSave : true,
//下面两个设置复选框,可以获取多条记录进行操作
multiSelect : true,
selectRowByCheck :true,
beforeInsert : function(reParam){
var isLeaf = ${isLeaf};
//alert(isLeaf);
if(!isLeaf){
return true;
}else{
alert("请选择末级栏目添加文章");
return false;
}
},
beforeSave : function(reqParam){
if (confirm("您确定要提交 吗?")){
return true;
}else{
return false;
}
},
//实现了返回当前页,真的好强大
saveSuccess : function(requestParameter) {
//alert(Sigma.$grid(mygrid));// Grid or grid id , 不需要双引号
Sigma.$grid(mygrid).dataset.cleanModifiedData(true);
Sigma.$grid(mygrid).getPageInfo().pageNum = Sigma.$grid(mygrid).getPageInfo().pageNum;
Sigma.$grid(mygrid).reload();
},
defaultRecord : {
title : '(请输入标题)',
shortTitle : '(简短标题)',
origin : '筛宝网',
author : 'admin',
releaseDate : '${nowDate?string('yyyy-MM-dd')}',
contentConfigId : 1
},
parameters : { channelId:<#if channelId??>${channelId}<#else>1</#if>,isLeaf:${isLeaf},isLeaf:${isLeaf},cc:[8,9] }
};
var mygrid = new Sigma.Grid( gridOption );
Sigma.Utils.onLoad( function(){
mygrid.render();
} );
//////////////////////////////////////////////////////////
function query() {
var param={
title : Sigma.U.getValue(Sigma.$('q_title'))
}
//alert( "在查询数据的request中, 将会有如下参数:\n\n"+Sigma.toQueryString(param) );
mygrid.query(param);
}
</script>
<script type="text/javascript">
function selectRecords(selectRecord){
//数据传递回去
$("#loading").html('loading.........');
$.ajax({
type: "post",
url : "/cms/article/article!jsonDel.action",
data: 'selectRecord='+selectRecord, //传递数据
cache : false,
dataType: "html", //接受数据格式,注意数据接受格式:html、json、xml等,哦原来是这里的原因,我晕 --- json 不行
error : function(json) {
},
success: function(json){
//alert("删除成功");
window.location.href="/cms/article/article!toList.action";
}
});
}
function openUrl(url){
alert(url);
}
</script>
</head>
<body style="padding:0px;margin:0px;">
<!--
<div style="padding-left:15px;padding-bottom:5px;width:98%;" align="right">
<form method="post">
<#if channelId??>
<input type="submit" value="添加文章" onclick="this.form.action='article!input.action?channelId=${channelId}';"/>
</#if>
<input type="button" value="删除" id="btn1" onclick="selectRecords( GT.$json(mygrid.getSelectedRecords() ) )" />
</form>
</div>
<a href="/cms/article/article!input.action">修改</a>
<input type="button" value="删除" id="btn1" onclick="selectRecords( GT.$json(mygrid.getSelectedRecords() ) )" />
-->
<div id="mygrid_container" style="border:0px solid #cccccc;background-color:#f3f3f3;padding:5px;width:100%;" >
<div id="message">
<#if actionMessages?size gt 0 || fieldErrors?size gt 0>
<div id="actionMessages">
<#list actionMessages as message>
<div style="color:red;">${message?default("你请求的页面出错了!")?html?replace("\r\n","<br>")}</div>
</#list>
<#list fieldErrors?keys as field>
<div style="color:red;">${field}:${fieldErrors[field]?default("你请求的页面出错了!")?html?replace("\r\n","<br>")}</div>
</#list>
</div>
</#if>
</div>
<table border='0' style="width:80%;">
<tr>
<td style="width:80%;align:right;">
<form name="queryForm" >
<div>
文章标题:
<input type="text" name="title" id="q_title">
<input type="button" class="gt-input-button" value="查询" onclick="query()" />
<input type="reset" class="gt-input-button" />
</div>
</form>
</td>
<td style="width:20%;align:left;">
<form class="ropt" method="post">
<#if isLeaf=="false">
<select onchange="var url=this.options[this.selectedIndex].value;if(url!=null&&url!=''){location=url;}">
<option>--选择添加类型--</option>
<option value="article!input.action?channelId=${channelId}&articleClass=1&isLeaf=${isLeaf}">添加文章</option>
<option value="article!input.action?channelId=${channelId}&articleClass=2&isLeaf=${isLeaf}">添加产品</option>
<option value="article!input.action?channelId=${channelId}&articleClass=3&isLeaf=${isLeaf}">快速普通添加店铺</option>
<option value="article!input.action?channelId=${channelId}&articleClass=4&isLeaf=${isLeaf}">快速添加商品</option>
<option value="article!input.action?channelId=${channelId}&articleClass=5&isLeaf=${isLeaf}">快速添加店铺</option>
</select>
</#if>
</form>
</td>
</tr>
</table>
</div>
</body>
</html>